import { Label } from 'cc';
import { JsonAsset } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { BUILD_NUMBER, SHORT_COMMIT_HASH } from '../ConfigConst';
import { Layout } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('HotVersionInfo')
export class HotVersionInfo extends Component {

    @property(JsonAsset)
    jsonAsset: JsonAsset = null;

    start() {
        let label = this.getComponent(Label);
        label.string = `res: ${this.jsonAsset?.json?.version} build: ${BUILD_NUMBER} hash: ${SHORT_COMMIT_HASH}`;
        label.updateRenderData(true);

        let parentLayout = this.node.parent?.getComponent(Layout);
        if (parentLayout) parentLayout.updateLayout();
    }

}

